<template>
    <div>
        <table>
            <tr>
                <td>姓名</td>
                <td>
                    <input type="text" v-model="state.levelName" />
                </td>
            </tr>

            <tr>
                <td></td>
                <td>
                    <input type="button" value="添加列表" @click="OK" />
                </td>
            </tr>
        </table>
    </div>
</template>

<script setup lang="ts">
import axios from 'axios';
import { reactive, toRefs } from 'vue';

let data: any = reactive({
    state: {
        "levelName": "",
    },
});
let { state } = toRefs(data);
const OK = () => {
    if (state.value.levelName == "") {
        alert("请输入等级名称");
    }
    let obj = {
        "levelName": state.value.levelName,
    }
    axios({
        url: '/api/Member/AddLevel',
        method: 'post',
        data: obj
    }).then((res) => {
        if (res.data.data > 0) {
            alert("添加成功");
        } else {
            alert("添加失败");
        }
    })

};
</script>

<style scoped></style>